package com.devframe.component.ftlprocess.freemarker.directive;

import java.io.IOException;
import java.util.Map;

import com.devframe.component.ftlprocess.FTLProcessGlobalConstants;


import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
/**
 * 
 *<pre><b><font color="blue">RenderDirective</font></b></pre>
 *
 *<pre><b>&nbsp;--描述说明--</b></pre>
 * <pre><@render></@render>展现指令的解析器</pre>
 * <pre>
 * <b>--样例--</b>
 *   RenderDirective obj = new RenderDirective();
 *   obj.method();
 * </pre>
 * @author  <b>詹保山</b>
 */
public class RenderDirective implements TemplateDirectiveModel {

	public void execute(Environment env, Map params, TemplateModel[] models,
			TemplateDirectiveBody body) throws TemplateException, IOException {
		
		//只有到了render解析器,render指令下的内容才会进行解析，否则不进行解析 
		Object val=env.getConfiguration().getSharedVariable(FTLProcessGlobalConstants.RESOLVE_SHARED_NAME);
		if(FTLProcessGlobalConstants.RESOLVE_RENDER_MARK.equals(val.toString())){
		     body.render(env.getOut());
		}
		
	}
}
